package view;

import java.util.List;

import model.Card;
import model.CardStack;

/** A contiguous substack of a stack. Represents the top [top] cards of stack [stack].
 */
public class StackFragment {
	public CardStack stack;
	public int top;
	public StackFragment(CardStack stack, int amount) {
		this.stack=stack;
		this.top = amount;
	}
	/** Does this selection contain the given card? */
	public boolean containsCard(Card c) {
		List<Card> cards = stack.getCards().subList(Math.max(0, stack.size()-top), stack.size());
		return cards.contains(c);
	}
	
	public String toMessage()
	{
		StringBuffer sb = new StringBuffer().append("stackfragment")
		.append("%").append(top).append("#").append(stack.toMessage());
		
		return sb.toString();
		
	}
}
